package mutsumimod.cards.deprecated;

import basemod.AutoAdd;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.AbstractPower;
import mutsumimod.cards.BaseCard;
import mutsumimod.character.Mutsumi;
import mutsumimod.util.CardStats;

@Deprecated
@AutoAdd.Ignore
public class QualityChecker extends BaseCard {
    public static final String ID = makeID(QualityChecker.class.getSimpleName());
    public static final CardStats info = new CardStats(
            Mutsumi.Meta.CARD_COLOR,
            CardType.SKILL,
            CardRarity.COMMON,
            CardTarget.ENEMY,
            1
    );

    public static final int BASE_DAMAGE=3;
    public static final int BASE_UPG_DAMAGE=4;

    public QualityChecker() {
        super(ID, info);
        setAttr(BASE_DAMAGE,0,0);
        setAttrUpg(BASE_UPG_DAMAGE-BASE_DAMAGE,0,0);
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        calculateCardDamage(m);
        damageMonster(m);
    }

//    @Override
//    public void updateDescription() {
//        rawDescription=cardStrings.DESCRIPTION;
//        if(AbstractDungeon.player==null||getDebuffNum(null)==0){
//            initializeDescription();
//            return;
//        }
//        setCustomVar("BD", baseDamage);
//        this.rawDescription += cardStrings.EXTENDED_DESCRIPTION[0];
//        initializeDescription();
//    }

    @Override
    public void calculateCardDamage(AbstractMonster mo){
        if (upgraded) {
            baseDamage = (int)(BASE_UPG_DAMAGE * Math.pow(2, getDebuffNum(mo)));
        } else {
            baseDamage = (int)(BASE_DAMAGE * Math.pow(2, getDebuffNum(mo)));
        }
        //updateDescription();
        super.calculateCardDamage(mo);
    }

    public int getDebuffNum(AbstractMonster monster){
        if(AbstractDungeon.player==null){
            return 0;
        }
        int count=0;
        for(AbstractPower p : AbstractDungeon.player.powers){
            if(p.type == AbstractPower.PowerType.DEBUFF){
                count++;
            }
        }
        if(monster!=null){
            for(AbstractPower p : monster.powers){
                if(p.type == AbstractPower.PowerType.DEBUFF){
                    count++;
                }
            }
        }
        return count;
    }

    @Override
    public void applyPowers() {
        if (upgraded) {
            baseDamage = (int)(BASE_UPG_DAMAGE * Math.pow(2, getDebuffNum(null)));
        } else {
            baseDamage = (int)(BASE_DAMAGE * Math.pow(2, getDebuffNum(null)));
        }
        super.applyPowers();
        //updateDescription();
    }

    @Override
    public AbstractCard makeCopy() { //Optional
        return new QualityChecker();
    }

}
